const { newEnforcer } = require('casbin');
const path = require('path');

async function main() {
    // 加载 Casbin 模型和策略
    const model = path.join(__dirname, 'rbac_model.conf');
    const policy = path.join(__dirname, 'rbac_policy.csv');

    // 创建 Enforcer 对象
    const enforcer = await newEnforcer(model, policy);

    // 检查权限
    const sub = 'alice'; // 用户 角色 
    const obj = 'data2'; // 资源  /order/add
    const act = 'write'; // 操作 get post put delete 
    const allowed = await enforcer.enforce(sub, obj, act);

}

main();